package com.example.demo.controller;

import com.alibaba.fastjson.JSONObject;
import com.example.demo.domain.SgBStoTobOutNotices;
import com.example.demo.service.SgBStoTobOutNoticesService;
import com.young.properties.ApplicationContextHandle;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class GreetingController {

    @Autowired
    SgBStoTobOutNoticesService sgBStoTobOutNoticesService;

    @GetMapping("/greet")
    public String greet(@RequestParam("name") String name) {
        SgBStoTobOutNoticesService bean = ApplicationContextHandle.getBean(SgBStoTobOutNoticesService.class);
        System.out.println("name = " + name);
        return "Hello, " + name + "!";
    }


    @GetMapping("/getNotices")
    public String getNotices(@RequestParam("billNo") String billNo) {
        System.out.println("GreetingController：" + Thread.currentThread().getName());
        SgBStoTobOutNotices sgBStoTobOutNotices = sgBStoTobOutNoticesService.queryByBillNo(billNo);
        return JSONObject.toJSONString(sgBStoTobOutNotices);
    }
}